package com.project.erp.common.utils;

import java.util.Comparator;

import com.google.common.collect.ComparisonChain;
import com.google.common.collect.Ordering;
import com.project.erp.model.system.User;

/**
 * 用户信息排序比较器
 * 
 * @author zyj
 * 
 */
public class UserComparator implements Comparator<User> {

	@Override
	public int compare(User user1, User user2) {
		return ComparisonChain.start()
				.compare(user1.getLoginName(), user2.getLoginName())
				.compare(user1.getCreateTime(), user2.getCreateTime())
				.compare(user1.getRealName(), user2.getRealName())
				.compare(user1.getEmail(), user2.getEmail(),Ordering.natural().nullsLast())
				.result();
	}
	
}
